import {defineAsyncComponent} from "vue";
// 注册ma-icon图标
const modules = import.meta.glob('../assets/ma-icons/*.vue', { eager: true })
export default {
  install(Vue) {
    Vue.component('MaChart', defineAsyncComponent(() => import('./ma-charts/index.vue')))
    Vue.component('MaCrud', defineAsyncComponent(() => import('./ma-crud/index.vue')))
    Vue.component('MaForm', defineAsyncComponent(() => import('./ma-form/index.vue')))
    Vue.component('MaUpload', defineAsyncComponent(() => import('./ma-upload/index.vue')))
    Vue.component('MaTreeSlider', defineAsyncComponent(() => import('./ma-treeSlider/index.vue')))
    Vue.component('MaResource', defineAsyncComponent(() => import('./ma-resource/index.vue')))
    Vue.component('MaResourceButton', defineAsyncComponent(() => import('./ma-resource/button.vue')))
    Vue.component('MaUser', defineAsyncComponent(() => import('./ma-user/index.vue')))
    Vue.component('MaEditor', defineAsyncComponent(() => import('./ma-editor/index.vue')))
    Vue.component('MaWangEditor', defineAsyncComponent(() => import('./ma-wangEditor/index.vue')))
    Vue.component('MaIcon', defineAsyncComponent(() => import('./ma-icon/index.vue')))
    Vue.component('MaCodeEditor', defineAsyncComponent(() => import('./ma-codeEditor/index.vue')))
    Vue.component('MaUserInfo', defineAsyncComponent(() => import('./ma-userInfo/index.vue')))
    Vue.component('MaCityLinkage', defineAsyncComponent(() => import('./ma-cityLinkage/index.vue')))
    for (const path in modules) {
      const name = path.match(/([A-Za-z0-9_-]+)/g)[2]
      const componentName = `MaIcon${name}`
      Vue.component(componentName, defineAsyncComponent(() => import(`../assets/ma-icons/${name}.vue`)))
    }
  }
}
